
/** WPI CS509 cisco Stratego MsgGetStats
 * 
 */
package edu.wpi.cs509.messages.server;

import edu.wpi.cs509.messages.MsgBc;
import edu.wpi.cs509.messages.client.MsgStatsReply;
import edu.wpi.cs509.representation.UserName;

/**
 * This message class gets the statistics for the specified user.
 * 
 * @author sparadis
 *
 */
public class MsgGetStats extends MsgServerContext {

	/**
	 * serializable version number
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * userName: who to get stats on
	 */
	protected UserName userName;
	
	/**
	 * Rank of this user
	 */
	protected int rank;
	
	/**
	 * Constructor
	 * @param userName: who to get stats on.
	 */
	public MsgGetStats(UserName userName, int r) {
		this.userName = userName;
		this.rank = r;
	}

	/**
	 * Get the users stats.
	 * @return MsgBc - the reply msg with the user's stats.
	 */
	@Override
	public MsgBc doExecuteAndGetReply() {
		//Get the specified user's stats, return it in a reply msg. 
		return (new MsgStatsReply(getServer().getPersonalStats(userName, this.getConnection()),rank));
	}

}

